<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<!-- GOOD FOR SEO -->
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="copyright" content="Copyright Â© 2011 YourWebsite.com">
    <meta name="author" content="Your Name">
    <meta name="designer" content="Your Name">
    <meta name="email" content="contact@email.com">
    <meta name="robots" content="index, follow">
    <meta name="googlebot" content="index, follow">
    <meta name="revisit-after" content="1 Day">
    <meta name="rating" content="General">
    <meta name="distribution" content="Global">
    <!-- GOOGLE VERIFY -->
    <meta name="google-site-verification" content="XXX-XXX-XXX" />
	<!-- ICON FAVI -->
    <link rel="icon" type="image/x-icon" href="images/favicon.png">
    <link rel="shortcut icon" type="image/x-icon" href="images/favicon.png"> 
    <!-- FACEBOOK META SHARE -->
    <meta property="og:title" content="" />
    <meta property="og:type" content="website" />
    <meta property="og:url" content="http://yourwebsite.com" />
    <meta property="og:image" content="http://yourwebsite.com/images/facebookimage.png" />
    <meta property="og:site_name" content="" />
    <meta property="og:description" content="" />

    <!-- TITLE OF WEBSITE -->
	<?php echo $this->headTitle()?>
	<!-- WEBSITE SCRIPT & SOURCE -->
	<link rel="stylesheet" href="<?php echo TempDefault?>css/reset.css">
	<link rel="stylesheet" href="<?php echo TempDefault?>css/style.css">
    <link rel="stylesheet" href="<?php echo TempDefault?>css/nivo-slider.css">
    <link rel="stylesheet" href="<?php echo TempDefault?>css/colorbox.css">
    <link rel="stylesheet" href="<?php echo TempDefault?>css/base/jquery.ui.all.css">
	<script src="<?php echo TempDefault?>js/jquery.1.7.2.min.js" type="text/javascript"></script>
    <script src="<?php echo TempDefault?>js/jquery.nivo.slider.js" type="text/javascript"></script>
    <script type="text/javascript" src="<?php echo TempDefault?>js/jquery.tinycarousel.min.js"></script>
    <script type="text/javascript" src="<?php echo TempDefault?>js/jquery.colorbox.js"></script>
	<script src="<?php echo TempDefault?>js/jquery.global.js" type="text/javascript"></script>
	
	<script src="<?php echo TempDefault?>js/jquery-ui-1.8.23.custom.js" type="text/javascript"></script>
    <script type="text/javascript">
        document.write('<style>.noscript { display: none; }</style>');
    </script>
</head>

<body>
	<!-- .container -->
    <div id="top"></div>
    <div class="wrapper">
    <!-- #header -->
       <?php echo $this->render("/public/header.phtml")?>
       <!-- /#header -->
		<?php echo $this->layout()->content?>
    </div>
    <!-- /.container -->
    <?php echo $this->render("/public/footer.phtml")?>

<script type="text/javascript">
	$(function() {
		// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
		$( "#dialog:ui-dialog" ).dialog( "destroy" );
		
		var name = $( "#name" ),
			company_name = $( "#company_name" ),
			email = $( "#email" ),
			content = $( "#content" ),
			allFields = $( [] ).add( name ).add( company_name ).add( content ),
			tips = $( ".validateTips" );

		function updateTips( t ) {
			tips
				.text( t )
				.addClass( "ui-state-highlight" );
			setTimeout(function() {
				tips.removeClass( "ui-state-highlight", 1500 );
			}, 500 );
		}

		function checkLength( o, n, min, max ) {
			if ( o.val().length > max || o.val().length < min ) {
				o.addClass( "ui-state-error" );
				updateTips( "Độ dài của " + n + " phải trong khoảng " +
					min + " và " + max + "." );
				return false;
			} else {
				return true;
			}
		}


		function checkRequired( o , n){
			if($.trim(o.val()).length == 0){
				o.addClass( "ui-state-error" );
				updateTips( "Trường " + n + " không được để trống");
				return false;
			}else{
				return true;
			}
				
		}
		
		function checkRegexp( o, regexp, n ) {
			if ( !( regexp.test( o.val() ) ) ) {
				o.addClass( "ui-state-error" );
				updateTips( n );
				return false;
			} else {
				return true;
			}
		}
		
		$( "#dialog-form" ).dialog({
			autoOpen: false,
			height: 400,
			width: 450,
			modal: true,
			resizable: false,
			buttons: {
				"<?php echo CONTACT_SUBMIT?>": function() {
					var bValid = true;
					allFields.removeClass( "ui-state-error" );
					
					bValid = bValid && checkRequired(name,"<?php echo CONTACT_NAME?>");
					bValid = bValid && checkRequired(company_name,"<?php echo CONTACT_COMPANY_NAME?>");
					bValid = bValid && checkRequired(content, "<?php echo CONTACT_CONTENT?>");

					bValid = bValid && checkLength( email, "email", 6, 80 );
					bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. abc@gmail.com" );
					
					if ( bValid ) {
					
						$.post("<?php echo DOMAIN?>/mail/contactadmin", { name: name.val(), company_name: company_name.val(), email: email.val() ,content: content.val() } ,function(data){
							alert(data);
							$(this).dialog("close");		
						});
						 
						
					}
				},
				"<?php echo CONTACT_CANCEL?>": function(){
					$(this).dialog("close");
				}
			},
			close: function() {
				allFields.val( "" ).removeClass( "ui-state-error" );
			}
		});

		$( "#support a" )
			.click(function() {
				$( "#dialog-form" ).dialog( "open" );
			});
	});
</script>    
    
<div id="dialog-form" title="<?php echo Contact?>">
	<p class="validateTips">Tất cả các dòng đều không được trống.</p>

	<form>
	<fieldset>
		<label for="name"><?php echo CONTACT_NAME?></label>
		<input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
		<label for="company_name"><?php echo CONTACT_COMPANY_NAME?></label>
		<input type="text" name="company_name" id="company_name" value="" class="text ui-widget-content ui-corner-all" />
		<label for="email"><?php echo CONTACT_EMAIL?></label>
		<input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />
		<label for="content"><?php echo CONTACT_CONTENT?></label>
		<textarea name="content" id="content" style="width: 411px; height: 102px;margin-top: 0px"></textarea>
	</fieldset>
	</form>
</div>    
    
</body>
</html>
